import Vue from 'vue'

import 'normalize.css/normalize.css' // A modern alternative to CSS resets
import { message } from '@/utils/resetMessage'
import ElementUI from 'element-ui'
// import 'element-ui/lib/theme-chalk/index.css'
import '@/styles/element-variables.scss'
import 'element-ui/lib/theme-chalk/icon.css'
// import locale from 'element-ui/lib/locale/lang/en' // lang i18n
import i18n from './lang' // internationalization
import '@/styles/index.scss' // global css
import App from './App'
import store from './store'
import router from './router'
import '@/icons' // icon

/* we-base-iconfont*/
import '@/assets/icon/iconfont.css'
import '@/assets/icon/iconfont.js'
import '@/assets/icon/iconfont_webaas.css'
import '@/permission' // permission control
import VueClipboard from 'vue-clipboard2'

/* 富文本*/
import tinymce from 'tinymce/tinymce'
import Editor from '@tinymce/tinymce-vue'
import 'tinymce/icons/default'
import 'tinymce/themes/silver/theme.min.js'
Vue.component('editor', Editor)

import 'viewerjs/dist/viewer.css'
import Viewer from 'v-viewer'
Vue.use(Viewer)

// 兼容实操练习
import { chooseLang } from './utils/errcode.js'
import errcode from './utils/errcode'
import JsonViewer from 'vue-json-viewer'
Vue.use(JsonViewer)

// error code
Vue.prototype.errcode = errcode
Vue.prototype.$chooseLang = chooseLang
// 只提示一次的弹窗
Vue.prototype.$messageOnce = message
/**
 * If you don't want to use mock-server
 * you want to use MockJs for mock api
 * you can execute: mockXHR()
 *
 * Currently MockJs will be used in the production environment,
 * please remove it before going online ! ! !
 */
// if (process.env.NODE_ENV === 'development') {
//   const { mockXHR } = require('../mock')
//   mockXHR()
// }

import * as dayjs from 'dayjs'
Vue.prototype.dayjs = dayjs

import * as filters from './utils/filters'
Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key])
})

Vue.filter('contractSource', function (value) {
  switch (value) {
    case '0x0000000000000000000000000000000000001000':
      return 'SystemConfig'
      break
    case '0x0000000000000000000000000000000000001001':
      return 'TableFactory'
      break
    case '0x0000000000000000000000000000000000001002':
      return 'CRUD'
      break
    case '0x0000000000000000000000000000000000001003':
      return 'Consensus'
      break
    case '0x0000000000000000000000000000000000001004':
      return 'CNS'
      break
    case '0x0000000000000000000000000000000000001005':
      return 'Permission'
      break
    case '0x0000000000000000000000000000000000001007':
      return 'CSM'
      break
    case '0x0000000000000000000000000000000000001008':
      return 'ChainGovern'
      break
    case '0x0000000000000000000000000000000000001009':
      return 'ChainCharge'
      break
    default:
      return ''
      break
  }
})

import { Tabs, Tab } from 'vue-tabs-component'

Vue.component('tabs', Tabs)
Vue.component('tab', Tab)
// set ElementUI lang to EN
Vue.use(ElementUI, {
  i18n: (key, value) => i18n.t(key, value)
})
// 如果想要中文版 element-ui，按如下方式声明
// Vue.use(ElementUI)
Vue.use(VueClipboard)

Vue.config.productionTip = false

new Vue({
  el: '#app',
  router,
  store,
  i18n,
  render: h => h(App)
})
